package com.nginx.web.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nginx.web.domain.HttpInfoQo;
import com.nginx.web.entity.UpstreamInfo;
import com.nginx.web.mapper.UpstreamInfoMapper;
import com.nginx.web.service.UpstreamInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lyc
 * @since 2025-01-15
 */
@Service
public class UpstreamInfoServiceImpl extends ServiceImpl<UpstreamInfoMapper, UpstreamInfo> implements UpstreamInfoService {

    public Page<UpstreamInfo> listUpstreamInfo(HttpInfoQo qo) {
        Page<UpstreamInfo> page = new Page<>(qo.getPage() , qo.getLimit());
        LambdaQueryWrapper<UpstreamInfo> wrapper = Wrappers.lambdaQuery(UpstreamInfo.class);
        if(qo.getConfInfoId() != null){
            wrapper.eq(UpstreamInfo::getConfInfoId , qo.getConfInfoId());
        }
        return page(page , wrapper);
    }

    public void updateUpstreamInfo(UpstreamInfo upstreamInfo) {
        updateById(upstreamInfo);
    }

}
